package com.lan.service.sys.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lan.entity.sys.UserRoleRel;
import com.lan.mapper.sys.UserRoleMapper;
import com.lan.service.sys.UserRoleService;

import javax.annotation.Resource;

public class UserRoleServiceImpl implements UserRoleService {

    @Resource
    private UserRoleMapper relUserRoleMapper;

    @Override
    public int deleteByUserId(final String userId) {
        LambdaQueryWrapper<UserRoleRel> queryWrapper = new QueryWrapper<UserRoleRel>()
                .lambda()
                .eq(UserRoleRel::getUserId, userId);
        return relUserRoleMapper.delete(queryWrapper);
    }

    @Override
    public int deleteByRoleId(final String roleId) {
        LambdaQueryWrapper<UserRoleRel> queryWrapper = new QueryWrapper<UserRoleRel>()
                .lambda()
                .eq(UserRoleRel::getRoleId, roleId);
        return relUserRoleMapper.delete(queryWrapper);
    }
}
